package com.jy.api.signUpReq.stock;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jy.api.domain.ProductMold;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * Created by xiaohua on 2018/7/16.
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class BarCheckReq {

    private String storeId;

    private String operatorId;

    /**
     * 操作人名称
     */
    private String operatorName;

    /**
     * 种类
     */
    private int kind;

    private String checkCode;

    /**
     * 备注
     */
    private String notes;

    private List<CheckBar> checkBar;

    /**
     * 总数量
     */
    private Integer countNum;

    private ProductMold mold;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor(suppressConstructorProperties = true)
    public static class CheckBar {

        @NotNull(message = "参数有误")
        private String  productId;

        @NotNull(message = "参数有误")
        private String productName;

        @NotNull(message = "参数有误")
        private int stockPrice;


        /**
         * 实际总个数
         */
        @NotNull(message = "参数有误")
        private int checkNum;
        /**
         * 应有个数
         */
        @NotNull(message = "参数有误")
        private int accurateNum;
        /**
         * 备注
         */
        private String notes;

        public String checkSockBarType() {
            if (checkNum == accurateNum) {
                return "NO";
            } else if (checkNum - accurateNum > 0) {
                return "CHECK-IN";
            } else {
                return "CHECK-OUT";
            }

        }
    }
}
